package javase.javase02.thread;

/**
 * @author: Gan
 * @date 2021/4/21 0021 10:22
 * @description:
 **/
public class DemoExercise01 {
    public static void main(String[] args) {
        TicketThread t = new TicketThread();
        Thread t1 = new Thread(t);
        t1.setName("售票员1");
        Thread t2 = new Thread(t);
        t2.setName("售票员2");
        Thread t3 = new Thread(t);
        t3.setName("售票员3");
        t1.start();
        t2.start();
        t3.start();
    }
}

class TicketThread implements Runnable {

    int ticketNum = 100;

    @Override
    public void run() {
        while (ticketNum >= 0) {
            System.out.println("第" + ticketNum + "张票卖掉了！");
            ticketNum --;
        }
    }
}